{% extends "base.html" %}
{% block title %}主页{% endblock %}
{% block content %}
<h2>欢迎{{current_user.username}}来到图书管理系统</h2>
<p>
    {% if not borrow_card %}
    您当前还没有借书证，去办理<a href="{{ url_for('user_card.card_view') }}">借书证</a>
    {% else %}
    您当前借书证信息如下：
    <ul>
        <li>借阅卡号: {{ borrow_card.card_id }}</li>
        <li>用户名: {{ current_user.username }}</li>
        <li>借阅上限: {{ borrow_card.borrow_limit }}</li>
        <li>有效期: {{ borrow_card.valid_until }}</li>
    </ul>
    {% endif %}
</p>
<table style="width:100%;border:1px">
    <tr>
        <td>编号</td>
        <td>书名</td>
        <td>作者</td>
        <td>价格</td>
        <td>库存</td>
        <td>是否上架</td>
        <td>操作</td>
    </tr>
    {% for book in books %}
    <tr>
        <td>{{ book.id }}</td>
        <td>{{ book.name }}</td>
        <td>{{ book.author }}</td>
        <td>{{ book.price }}</td>
        <td>{{ book.available_count }}</td>
        <td>{{ book.is_active | is_active_filter }}</td>
        <td>
            <a href="{{ url_for('user_borrow.borrow_info', book_id=book.id) }}">去借书</a>
        </td>
    </tr>
    {% endfor %}
</table>
<p>当前一共有{{books|length}}本书</p>
</br>

{% endblock %}